#define _CRT_SECURE_NO_WARNINGS 1



#include<stdio.h>

int fun(int y)
{
	if ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0)
		return 1;
	else
		return 0;
}
int main()
{
	int year = 0, month = 0, day = 0, i = 0, sum = 0, arr[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	scanf("%d %d %d", &year, &month, &day);
	if (fun(year) == 1)
		arr[2]++;
	for (i = 0; i < month; i++)
		sum += arr[i];
	printf("%d\n", sum + day);

	return 0;
}